from pms.common.views import PostFormula
from project.models import ProjectCodeRepository, Project


class API(PostFormula):
    def handle(self, req):
        pid = req['pid']
        repos = ProjectCodeRepository.objects.filter(
            pid=Project.objects.get(id=pid)
        )
        return self.success_respond({
            'list': [{
                'id': repo.id,
                'name': repo.name,
                'href': repo.href
            } for repo in repos]
        })
